﻿'
' Will Strohl (will.strohl@gmail.com)
' http://www.willstrohl.com
'
'Copyright (c) 2011, Will Strohl
'All rights reserved.
'
'Redistribution and use in source and binary forms, with or without modification, are 
'permitted provided that the following conditions are met:
'
'Redistributions of source code must retain the above copyright notice, this list of 
'conditions and the following disclaimer.
'
'Redistributions in binary form must reproduce the above copyright notice, this list 
'of conditions and the following disclaimer in the documentation and/or other 
'materials provided with the distribution.
'
'Neither the name of Will Strohl nor the names of its contributors may be 
'used to endorse or promote products derived from this software without specific prior 
'written permission.
'
'THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY 
'EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 
'OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT 
'SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 
'INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED 
'TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR 
'BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 
'CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN 
'ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH 
'DAMAGE.
'

Imports DotNetNuke.Common.Utilities
Imports DotNetNuke.Entities.Modules
Imports DotNetNuke.Services.Exceptions

Imports WillStrohl.Modules.CodeCamp.SessionInfoMembers

Namespace WillStrohl.Modules.CodeCamp

    <Serializable()> _
    Public NotInheritable Class SessionInfo
        Implements ISessionInfo, IHydratable

#Region " Private Members "

        Private p_Approved As Boolean = Null.NullBoolean
        Private p_ApprovedByDate As DateTime = Null.NullDate
        Private p_ApprovedByUser As Integer = Null.NullInteger
        Private p_AudienceLevel As Integer = Null.NullInteger
        Private p_CreatedByDate As DateTime = Null.NullDate
        Private p_CreatedByUser As Integer = Null.NullInteger
        Private p_Description As String = Null.NullString
        Private p_NumberRegistered As Integer = Null.NullInteger
        Private p_RoomId As Integer = Null.NullInteger
        Private p_SessionId As Integer = Null.NullInteger
        Private p_TimeSlotId As Integer = Null.NullInteger
        Private p_Title As String = Null.NullString
        Private p_TrackId As Integer = Null.NullInteger

#End Region

#Region " Public Properties "

        Public Property Approved() As Boolean Implements ISessionInfo.Approved
            Get
                Return Me.p_Approved
            End Get
            Set(ByVal value As Boolean)
                Me.p_Approved = value
            End Set
        End Property

        Public Property ApprovedByDate() As Date Implements ISessionInfo.ApprovedByDate
            Get
                Return Me.p_ApprovedByDate
            End Get
            Set(ByVal value As Date)
                Me.p_ApprovedByDate = value
            End Set
        End Property

        Public Property ApprovedByUser() As Integer Implements ISessionInfo.ApprovedByUser
            Get
                Return Me.p_ApprovedByUser
            End Get
            Set(ByVal value As Integer)
                Me.p_ApprovedByUser = value
            End Set
        End Property

        Public Property AudienceLevel As Integer Implements ISessionInfo.AudienceLevel
            Get
                Return Me.p_AudienceLevel
            End Get
            Set(ByVal value As Integer)
                Me.p_AudienceLevel = value
            End Set
        End Property

        Public Property CreatedByDate() As Date Implements ISessionInfo.CreatedByDate
            Get
                Return Me.p_CreatedByDate
            End Get
            Set(ByVal value As Date)
                Me.p_CreatedByDate = value
            End Set
        End Property

        Public Property CreatedByUser() As Integer Implements ISessionInfo.CreatedByUser
            Get
                Return Me.p_CreatedByUser
            End Get
            Set(ByVal value As Integer)
                Me.p_CreatedByUser = value
            End Set
        End Property

        Public Property Description() As String Implements ISessionInfo.Description
            Get
                Return Me.p_Description
            End Get
            Set(ByVal value As String)
                Me.p_Description = value
            End Set
        End Property

        Public Property NumberRegistered() As Integer Implements ISessionInfo.NumberRegistered
            Get
                Return Me.p_NumberRegistered
            End Get
            Set(ByVal value As Integer)
                Me.p_NumberRegistered = value
            End Set
        End Property

        Public Property RoomId() As Integer Implements ISessionInfo.RoomId
            Get
                Return Me.p_RoomId
            End Get
            Set(ByVal value As Integer)
                Me.p_RoomId = value
            End Set
        End Property

        Public Property SessionId() As Integer Implements ISessionInfo.SessionId
            Get
                Return Me.p_SessionId
            End Get
            Set(ByVal value As Integer)
                Me.p_SessionId = value
            End Set
        End Property

        Public Property TimeSlotId() As Integer Implements ISessionInfo.TimeSlotId
            Get
                Return Me.p_TimeSlotId
            End Get
            Set(ByVal value As Integer)
                Me.p_TimeSlotId = value
            End Set
        End Property

        Public Property Title() As String Implements ISessionInfo.Title
            Get
                Return Me.p_Title
            End Get
            Set(ByVal value As String)
                Me.p_Title = value
            End Set
        End Property

        Public Property TrackId() As Integer Implements ISessionInfo.TrackId
            Get
                Return Me.p_TimeSlotId
            End Get
            Set(ByVal value As Integer)
                Me.p_TimeSlotId = value
            End Set
        End Property

#End Region

        Public Sub New()
            ' do nothing
        End Sub

#Region " IHydratable Implementation "

        Public Property KeyID() As Integer Implements DotNetNuke.Entities.Modules.IHydratable.KeyID
            Get
                Return Me.p_SessionId
            End Get
            Set(ByVal value As Integer)
                Me.p_SessionId = value
            End Set
        End Property

        Public Sub Fill(ByVal dr As System.Data.IDataReader) Implements DotNetNuke.Entities.Modules.IHydratable.Fill
            Try
                While dr.Read
                    If Not dr.Item(ApprovedField) Is Nothing Then
                        Me.p_Approved = Boolean.Parse(dr.Item(ApprovedField).ToString)
                    End If
                    If Not dr.Item(CreatedByDateField) Is Nothing Then
                        If IsDate(dr.Item(CreatedByDateField)) Then
                            Me.p_ApprovedByDate = Date.Parse(dr.Item(CreatedByDateField).ToString)
                        End If
                    End If
                    If Not dr.Item(CreatedByUserField) Is Nothing Then
                        Me.p_ApprovedByUser = Integer.Parse(dr.Item(CreatedByUserField).ToString, Globalization.NumberStyles.Integer)
                    End If
                    If Not dr.Item(CreatedByDateField) Is Nothing Then
                        If IsDate(dr.Item(CreatedByDateField)) Then
                            Me.p_CreatedByDate = Date.Parse(dr.Item(CreatedByDateField).ToString)
                        End If
                    End If
                    If Not dr.Item(CreatedByUserField) Is Nothing Then
                        Me.p_CreatedByUser = Integer.Parse(dr.Item(CreatedByUserField).ToString, Globalization.NumberStyles.Integer)
                    End If
                    If Not dr.Item(DescriptionField) Is Nothing Then
                        Me.p_Description = dr.Item(DescriptionField).ToString
                    End If
                    If Not dr.Item(AudienceLevelField) Is Nothing Then
                        Me.p_AudienceLevel = Integer.Parse(dr.Item(AudienceLevelField).ToString, Globalization.NumberStyles.Integer)
                    End If
                    If Not dr.Item(NumberRegisteredField) Is Nothing Then
                        If IsNumeric(dr.Item(NumberRegisteredField)) Then
                            Me.p_NumberRegistered = Integer.Parse(dr.Item(NumberRegisteredField).ToString, Globalization.NumberStyles.Integer)
                        End If
                    End If
                    If Not dr.Item(RoomIdField) Is Nothing Then
                        If IsNumeric(dr.Item(RoomIdField)) Then
                            Me.p_RoomId = Integer.Parse(dr.Item(RoomIdField).ToString, Globalization.NumberStyles.Integer)
                        End If
                    End If
                    If Not dr.Item(SessionIdField) Is Nothing Then
                        Me.p_SessionId = Integer.Parse(dr.Item(SessionIdField).ToString, Globalization.NumberStyles.Integer)
                    End If
                    If Not dr.Item(TimeSlotIdField) Is Nothing Then
                        If IsNumeric(dr.Item(TimeSlotIdField)) Then
                            Me.p_TimeSlotId = Integer.Parse(dr.Item(TimeSlotIdField).ToString, Globalization.NumberStyles.Integer)
                        End If
                    End If
                    If Not dr.Item(TitleField) Is Nothing Then
                        Me.p_Title = dr.Item(TitleField).ToString
                    End If
                    If Not dr.Item(TrackIdField) Is Nothing Then
                        If IsNumeric(dr.Item(TrackIdField)) Then
                            Me.p_TrackId = Integer.Parse(dr.Item(TrackIdField).ToString, Globalization.NumberStyles.Integer)
                        End If
                    End If
                End While
            Catch ex As Exception
                LogException(ex)
            Finally
                If Not dr.IsClosed Then
                    dr.Close()
                End If
            End Try
        End Sub

#End Region

    End Class

End Namespace